package com.jiaozi.system.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.jiaozi.base.utils.bean.R;
import com.jiaozi.core.annotation.Log;
import com.jiaozi.core.table.JzTable;
import com.jiaozi.system.pojo.param.sys.post.PostListParam;
import com.jiaozi.system.pojo.param.sys.post.PostSaveUpdateParam;
import com.jiaozi.system.pojo.param.sys.role.RoleSaveUpdateParam;
import com.jiaozi.system.pojo.vo.sys.post.SysPostListVO;
import com.jiaozi.system.pojo.vo.sys.role.RoleInfoVO;
import com.jiaozi.system.service.SysPostService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;


/**
 * 系统-岗位(SysPost)表控制层
 *
 * @author 张崇阳
 * @since 2024-10-31 10:45:11
 */
@RestController
@RequestMapping("/sysPost")
public class SysPostController {
    /**
     * 服务对象
     */
    @Autowired
    private SysPostService sysPostService;
    @Operation(summary = "岗位初始化",description = "岗位初始化")
    @GetMapping("/info")
    @ApiOperationSupport(order = 1)
    @Log("用户初始化")
    public R<JzTable> info(){
        JzTable jzTable=new JzTable(SysPostListVO.class);
        jzTable.setRefreshBotton(true);
        jzTable.setQueryCriteriaBotton(true);
        jzTable.setColumnsBotton(true);
        jzTable.setPage(true);
        jzTable.setDataUrl("/sysPost/page/");
        return R.ok(jzTable);
    }
    @Operation(summary = "分页岗位列表",description = "分页岗位列表")
    @GetMapping("/page/{pageNum}/{pageSize}")
    @ApiOperationSupport(order = 1)
    @Log("分页查询岗位信息")
    public R<IPage<SysPostListVO>> postPage(@Parameter(name ="pageNum" ,description = "页码", required = true)
                                         @PathVariable(value = "pageNum") Long pageNum,
                                         @Parameter(name ="pageSize" ,description = "页条数", required = true)
                                         @PathVariable(value = "pageSize") Long pageSize,
                                            PostListParam param
    ){
        return sysPostService.postPage(pageNum, pageSize, param);
    }




    @Operation(summary = "获取岗位信息",description = "获取岗位信息")
    @GetMapping("/{postId}")
    @ApiOperationSupport(order = 2)
    public R<SysPostListVO> postInfo(@Parameter(name ="postId" ,description = "岗位编号", required = true)
                                  @PathVariable(value = "postId") String postId){
        return sysPostService.postInfo(postId);

    }

    @Operation(summary = "新增岗位信息",description = "新增岗位信息")
    @PostMapping("/")
    @ApiOperationSupport(order = 3)
    public R savePost(@RequestBody PostSaveUpdateParam param){
        return sysPostService.savePost(param);
    }


    @Operation(summary = "修改岗位信息",description = "修改岗位信息")
    @PutMapping("/{postId}")
    @ApiOperationSupport(order = 4)
    public R updatePost(@Parameter(name ="postId" ,description = "岗位编号", required = true)
                        @PathVariable(value = "postId") String postId,@RequestBody PostSaveUpdateParam param){
        return sysPostService.updatePost(postId,param);
    }


    @Operation(summary = "删除岗位信息",description = "删除岗位信息")
    @DeleteMapping("/{postId}")
    @ApiOperationSupport(order = 4)
    public R deletePost(@Parameter(name ="postId" ,description = "岗位编号", required = true)
                        @PathVariable(value = "postId") String postId){
        return sysPostService.deletePost(postId);
    }


    @Operation(summary = "变更岗位状态",description = "变更岗位状态")
    @PutMapping("/updatePostStatus/{postId}")
    @ApiOperationSupport(order = 65)
    public R updatePostStatus(@Parameter(name ="postId" ,description = "岗位编号", required = true)
                             @PathVariable(value = "postId") String postId){
        return sysPostService.updatePostStatus(postId);
    }


}

